<template>
  <page-form :x-uri="uri" :bind-options="options" :bind-rules="rules">
    <!-- 自定义tab -->
    <template v-slot:page-tabs>
      <tabs :tabs="tabs" />
    </template>
  </page-form>
</template>

<script>
import PageForm from '@public/template/page_form.vue';
import Tabs from '../tabs';
export default {
  components: {
    PageForm,
    Tabs
  },
  data() {
    return {
      uri: '/course/admin/coupon/offline/couponCard/create',
      tabs: [
        {
          title: '添加优惠券',
          uri: '/market/coupon/offline/couponCard/create',
          meta: {
            permission: 'market.coupon.offline.couponcard.create'
          }
        }
      ],
      options: {
        use_time: {
          disabledDate: function(time) {
            return time.getTime() + 8.64e7 < Date.now();
          }
        },
        derive_time: {
          disabledDate: function(time) {
            return time.getTime() + 8.64e7 < Date.now();
          }
        }
      },
      rules: {
        issue_no: [
          { required: true, message: '期号必须填写', trigger: ['blur', 'change'] },
          {
            validator: (rule, value, callback) => {
              const reg = /^[\d\.\w_]+$/;
              if (!reg.test(value)) {
                return callback(new Error('节点标识由字母、数字、下划线和英文点`.`组成'));
              }
              callback();
            },
            trigger: ['blur', 'change']
          }
        ]
      }
    };
  }
};
</script>
